package org.aeon.client.handler.Inbound;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.aeon.client.context.GlobalContext;
import org.aeon.message.response.GroupInfoResponseMessage;

import static org.aeon.client.context.MessageMap.MessageContextKey.GroupInfo;


/**
 * @author: MissingAeon
 * @date: 2024/2/23 11:36
 * @description:
 */
@Slf4j
@ChannelHandler.Sharable
public class GroupInfoResponseHandler extends SimpleChannelInboundHandler<GroupInfoResponseMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, GroupInfoResponseMessage msg) throws Exception {
        if (msg.isSuccess()) {
            GlobalContext.getContext().getMessageMap().set(GroupInfo, msg.getGroupInfo());
        }
        ctx.fireChannelRead(msg);
    }
}
